import java.util.*;

public class PrimeNumbers {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int inputNumber = 0;

        // Wait for correct number input:
        while (inputNumber < 1) {
            System.out.print(Messages.INPUT_REQUEST);
            try {
                inputNumber = Integer.parseInt(scanner.nextLine());
                if (inputNumber < 1) {
                    throw new IllegalArgumentException(Messages.WRONG_NUMBER);
                }
                break;
            } catch (NumberFormatException e) {
                System.out.println(Messages.NOT_A_NUMBER);
            } catch (IllegalArgumentException e) {
                System.out.println(e.getMessage());
            }
        }

        System.out.printf(Messages.ENTERED_NUMBER, inputNumber);
        System.out.println(Messages.PRIME_NUMBERS_RESULT);

        NUMBERS:
        for (int number = 2; number < inputNumber; number++) {
            // Prime check:
            for (int divider = 2; divider < number; divider++) {
                // If number is dividable:
                if (number % divider == 0) {
                    continue NUMBERS; // not prime
                }
            }
            // Is prime:
            System.out.println(number);
        }
    }

}